fix(validator): project validation messages for a host that starts invalid - #2374
Conversation
…valid The container's first render is neutral for SSR parity and `create` skips the light DOM projection slots until the host has updated. A host that hydrated invalid (`<igc-input required invalid>`) never re-rendered, so its validation messages stayed hidden. The container now asks the host for a follow-up render from `firstUpdated` when it is invalid. Also: - cache kebab-cased slot names at module load instead of per render - take the projected-slot set in `_renderHelper` and make the render helpers private - tighten comments and the `target` docs; the `?invalid` note wrongly claimed the internal events cover failed submissions - add specs for the initially invalid host and the `create()` config
There was a problem hiding this comment.
🟡 Changes recommended
create() currently treats an omitted hasHelperText as false (disabling helper text when config is provided), and the updated spec should include the required accessibility audit assertions to match project testing conventions.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Fixes a hydration/SSR-parity edge case where a form control that starts out invalid never triggers the follow-up host render needed for projecting validation-message slots, leaving validation messages hidden. The container now prompts a host re-render from firstUpdated when starting invalid, and the PR also refactors slot-name handling and expands specs around initial-invalid and create() configuration behavior.
Changes:
- Request a follow-up host render from the container’s
firstUpdated()when the host hydrates invalid so validation slots can be projected. - Refactor validation slot name generation by caching kebab-cased slot names at module load and tightening internal helper APIs.
- Add/extend specs for the “initially invalid host” case and
create()configuration behavior.
File summaries
| File | Description |
|---|---|
| src/components/validation-container/validation-container.ts | Updates slot generation and lifecycle behavior to ensure projected validation messages appear when the host starts invalid. |
| src/components/validation-container/validation-container.spec.ts | Adds coverage for initially-invalid hosts and create() config scenarios (with suggested additions for a11y + default helper slot behavior). |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const helperText = config.hasHelperText | ||
| ? html`<slot name="helper-text" slot="helper-text"></slot>` | ||
| : nothing; |
| it('projects a helper-text slot by default', async () => { | ||
| const container = await createContainer(); | ||
|
|
||
| expect(container.id).to.equal(helperSlot); | ||
| expect(container.querySelector(projectedHelperSlot)).not.to.be.null; | ||
| }); |
| it('applies the id, slot and part from the configuration', async () => { | ||
| const container = await createContainer({ | ||
| id: 'custom-id', | ||
| slot: 'anchor', | ||
| part: 'custom-part', | ||
| }); | ||
|
|
||
| expect(container.id).to.equal('custom-id'); | ||
| expect(container.slot).to.equal('anchor'); | ||
| expect(container.part.contains('custom-part')).to.be.true; | ||
| }); |
Description
The container's first render is neutral for SSR parity and
createskips the light DOM projection slots until the host has updated. A host that hydrated invalid (<igc-input required invalid>) never re-rendered, so its validation messages stayed hidden. The container now asks the host for a follow-up render fromfirstUpdatedwhen it is invalid.Also:
_renderHelperand make the render helpers privatetargetdocs; the?invalidnote wrongly claimed the internal events cover failed submissionscreate()configType of Change
Checklist